namespace RFS.Domain.PaiShi
{
    public class Product : IProduct
    {
        public Product(string supplier, string name, string length)
        {
            Supplier = supplier;
            Name = name;
            Length = length;
        }

        public Product()
        {
        }

        public override string ToString()
        {
            return Key;
        }

        public string Supplier { get;  private set; }
        public string Name { get;  private set; }
        public string Length { get; private  set; }
        public string Key { get=>$"{Supplier}|{Name}|{Length}"; }


        public override bool Equals(object obj)
        {
            if (obj is IProduct p)
            {
                return p.Key==Key;
            }
            
            return false;
            
        }
        public override int GetHashCode()
        {
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + Key.GetHashCode();
                // hash = hash * 23 + (Name != null ? Name.GetHashCode() : 0);
                return hash;
            }
        }
        
    }
}